﻿@model IEnumerable<OAWeb.Models.StudentScore>
@Scripts.Render("~/bundles/jquery")

@{
    /**/

    double[,] score = new double[20, 5];
    score[0, 0] = 50;
    score[0, 1] = 70;
    score[0, 2] = 80;

    score[0, 0] = 50;
    score[0, 1] = 70;
    score[0, 2] = 80;

    //要把成绩表转为二维数组




}
@{

   @* for (int i = 0; i < ViewBag.stu.Length; i++)
    {
        for (int j = 0; j < ViewBag.cours.Length; j++)
        {
            //判断学生是否录入考试
            for (int k = 0; k < ViewBag.grades.Length; k++)
            {
                if (ViewBag.grades[k].StudentID == ViewBag.stu[i].ID)
                {
                    ViewBag.scores[i, j] = Model.Single(g => g.StdNumber == ViewBag.stu[i].ID && g.CourseName == ViewBag.cours[j].Subject).Score;
                    //break;
                }

            }

        }

    }*@
}

<table class="table">
    <tr>
        <td>学号</td>
        <td>姓名</td>

        @for (int j = 0; j < ViewBag.cours.Length; j++)
        {
            <td> @ViewBag.cours[j].Subject</td>
        }

        <td>总分</td>
        <td>班级排名</td>
        <td>年级排名</td>
        <td></td>
    </tr>

    @{






        //string[,] s = new string[ViewBag.stu.Length, 7];
        //double[] ssum = new double[ViewBag.cours.Length];
        //double sum = 0;
        //double avg = 0;

        //int stuLength = 0;

        //for (int c = 0; c < ViewBag.cours.Length; c++)
        //{
        //    for (int d = 0; d < ViewBag.grades1.Length; d++)
        //    {
        //        sum += ViewBag.scores[d, c];
        //    }
        //    ssum[c] = sum / ViewBag.grades1.Length;
        //}


        //int e = 2;
        //for (int i = 0; i < ViewBag.stu.Length; i++)
        //{
        //    e = 2;
        //    for (int k = 0; k < ViewBag.grades.Length; k++)
        //    {
        //        if (ViewBag.grades[k].StudentID == ViewBag.stu[i].ID)
        //        {

        //            double scoretotal = 0;


        //            for (int j = 0; j < ViewBag.cours.Length; j++)
        //            {


        //                scoretotal += ViewBag.scores[i, j];

        //            }




        //            s[i, 0] = ViewBag.stu[i].Number;
        //            s[i, 1] = ViewBag.stu[i].Name;
        //            for (int i1 = 0; i1 < ViewBag.cours.Length; i1++)
        //            {
        //                s[i, 2 + i1] = ViewBag.scores[i, i1].ToString();
        //                e++;
        //            }

        //            s[i, e] = scoretotal.ToString();
        //            s[i, e + 1] = ViewBag.stu[i].ID.ToString();

        //            stuLength++;
        //        }

        //    }

        //}

        //avg = sum / stuLength;

        //for (int c = 0; c < stuLength - 1; c++)
        //{
        //    for (int a = 0; a < stuLength - 1; a++)
        //    {
        //        if (int.Parse(s[a, e]) < int.Parse(s[a + 1, e]))
        //        {
        //            for (int b = 0; b < ViewBag.cours.Length + 4; b++)
        //            {
        //                string[,] s1 = new string[ViewBag.cours.Length, ViewBag.cours.Length + 4];
        //                s1[a, b] = s[a, b];
        //                s[a, b] = s[a + 1, b];
        //                s[a + 1, b] = s1[a, b];
        //            }
        //        }
        //    }

        //}
        int stuLength = ViewBag.stuLength;
        string[,] s = ViewBag.s;
        int e = ViewBag.e;
        double[] ssum = ViewBag.ssum;
        double avg = ViewBag.avg;
        for (int i = 0; i < stuLength; i++)
        {
            int count = 0;
            <tr>
                <td>@s[i, 0]</td>
                <td>@s[i, 1]</td>
                @for (int i1 = 0; i1 < ViewBag.cours.Length; i1++)
                {
                    <td>@s[i, 2 + i1]</td>
                }

                <td>@s[i, e]</td>
                <td>@(i + 1)</td>

                <td>
                    @foreach (KeyValuePair<string, double> d in ViewBag.dict)
                    {
                        count++;

                        if (s[i, e + 1] == d.Key)
                        {

                            @count
                                    }

                    }


                </td>



            </tr>
        }

        <tr>
            <td>全班平均分</td>
            <td></td>
            @for (int i = 0; i < ViewBag.cours.Length; i++)
            {
                <td>@Math.Round(ssum[i], 2)</td>
            }
            <td>@Math.Round(avg, 2)</td>
            <td></td>
        </tr>

    }
</table>


